package com.jingsheng.jingshengcity.mvp.ui.activity;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.UiUtils;
import com.jingsheng.jingshengcity.R;
import com.jingsheng.jingshengcity.di.component.DaggerMyOrderComponent;
import com.jingsheng.jingshengcity.di.module.MyOrderModule;
import com.jingsheng.jingshengcity.mvp.contract.MyOrderContract;
import com.jingsheng.jingshengcity.mvp.presenter.MyOrderPresenter;
import com.jingsheng.jingshengcity.mvp.ui.adapter.MyOrderTabAdapter;

import butterknife.BindView;

import static com.jess.arms.utils.Preconditions.checkNotNull;

/**
 * Created by Administrator on 2017/5/10.
 */

public class MyOrderActivity extends BaseActivity<MyOrderPresenter> implements MyOrderContract.View {

    @NonNull
    @BindView(R.id.tab_layout)
    TabLayout mTabLayout;
    @NonNull
    @BindView(R.id.vp_fragment)
    ViewPager mViewPager;

    private String mTabTitle[] = new String[]{"全部", "待付款", "待发货", "待收货", "待评价", "退款", "已完成"};

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerMyOrderComponent
                .builder()
                .appComponent(appComponent)
                .myOrderModule(new MyOrderModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView() {
        setTitle("我的订单");
        return R.layout.activity_my_order;
    }

    @Override
    public void initData() {
        MyOrderTabAdapter adapter = new MyOrderTabAdapter(getSupportFragmentManager(), mTabTitle);
        mViewPager.setAdapter(adapter);
        mViewPager.setOffscreenPageLimit(mTabTitle.length);
        mTabLayout.setupWithViewPager(mViewPager);
    }


    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        UiUtils.SnackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        UiUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }


}